package com.moons.uvcdemo.utils;

import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.moons.uvcdemo.config.DemoConfig;
//import com.moons.uvcdemo.DaoSession;
import com.moons.uvcdemo.model.DaoMaster;
import com.moons.uvcdemo.model.DaoSession;

public class ApplicationMe extends Application {
		private static Context mContext = null;
	private DaoSession daoSession;
	private static ApplicationMe instance;
	public static ApplicationMe getInstance() {

		return instance;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		// Log.i(Global.TAG, "application of speech remote has created.");
		mContext = getApplicationContext();
		instance = this;
		DemoConfig.getInstance().updateFolder();
		DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(getApplicationContext(), DemoConfig.DATABASE_NAME);
		SQLiteDatabase db = helper.getWritableDatabase();
		DaoMaster daoMaster = new DaoMaster(db);
		daoSession = daoMaster.newSession();
	}

	public DaoSession getDaoSession() {
		return daoSession;
	}
	/**
	 * Called when the overall system is running low on memory
	 */
	@Override
	public void onLowMemory() {
		super.onLowMemory();
//		Log.w(TAG, "System is running low on memory");
	}

	public static Context getAppContext() {
		return mContext;
	}
	/**
	 * @return the main resources from the Application
	 */
	public static Resources getAppResources() {
		if (mContext == null)
			return null;
		return mContext.getResources();
	}

}